// pages/mainTab/mine/mine.js
import RunData from "../../../config/runData";

Page({
    headImg:{
        male:"../../../images/user_male_icon.png",
        female:"../../../images/user_female_icon.png"
    },
    notLogin: {
        userName:"未登录",
        headImage:"../../../images/iconlogin.png"
    },
    /**
     * 页面的初始数据
     */
    data: {
        userName:"未登录",
        headImage:"../../../images/iconlogin.png"
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {

    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },
    onShow:function () {
        if(RunData.MyUserInfo){
            if(RunData.MyUserInfo.isMan()){
                this.setData({
                    userName:RunData.MyUserInfo.name,
                    headImage:this.headImg.male
                });
            }else{
                this.setData({
                    userName:RunData.MyUserInfo.name,
                    headImage:this.headImg.female
                });
            }
        }else{
            this.setData(this.notLogin);
        }
    },
    login:()=>{
        if(!RunData.MyUserInfo){
            wx.navigateTo({
                url:"../../login/login"
            })
        }else{
            wx.navigateTo({
                url:"../../mineInfo/mineInfo"
            })
        }
    },
    guahao(){
        wx.showToast({title: '开发中', icon: 'none', duration: 3000});
    },
    jiaofei(){
        if(RunData.MyUserInfo){
            wx.navigateTo({
                url:"../../payment/payment"
            })
        }else{
            wx.showToast({title: '请先登录', icon: 'none', duration: 3000});
        }
    },
    report(){
        if(RunData.MyUserInfo){
            wx.navigateTo({
                url:"../../myReport/myReport"
            })
        }else{
            wx.showToast({title: '请先登录', icon: 'none', duration: 3000});
        }
    }
});